package com.commerce.img.tools;

import android.content.Context;

import com.commerce.img.entity.DataUrl;
import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class JsonToList {
    public DataUrl JsonToList(Context context) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            BufferedReader bf = new BufferedReader(new InputStreamReader(
                    context.getAssets().open("img.json")));
            String line;
            while ((line = bf.readLine()) != null) {
                stringBuilder.append(line);
            }
            Gson gson = new Gson();
            DataUrl bean = gson.fromJson(stringBuilder.toString(), DataUrl.class);
            return bean;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
